package com.restaurant.application.indexes.consumptionlist.mysql;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import com.nebutown.generation.basictype.UID;

import java.util.List;

public class ConsumptionListBean implements PickableBean {

    public static final String FN_RECORDID = "recordId";
    public static final String FN_CONSUMPTIONUID = "consumptionUid";
    public static final String FN_TOTALPRICE = "totalPrice";
    public static final String FN_FINALPRICE = "finalPrice";
    public static final String FN_TIME = "time";
    public static final String FN_SHOPUID = "shopUID";
    public static final String FN_SHOPNAME = "shopName";
    public static final String FN_ACCUMULATEPOINTS = "accumulatePoints";
    public static final String FN_CUSTOMERUID = "customerUid";
    public static final String FN_CUSTOMERNAME = "customerName";
    public static final String FN_WECHATID = "weChatId";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_RECORDID,
             FN_CONSUMPTIONUID,
             FN_TOTALPRICE,
             FN_FINALPRICE,
             FN_TIME,
             FN_SHOPUID,
             FN_SHOPNAME,
             FN_ACCUMULATEPOINTS,
             FN_CUSTOMERUID,
             FN_CUSTOMERNAME,
             FN_WECHATID);

    private Long recordId;
    private UID consumptionUid;
    private Double totalPrice;
    private Double finalPrice;
    private Long time;
    private String shopUID;
    private String shopName;
    private Long accumulatePoints;
    private UID customerUid;
    private String customerName;
    private String weChatId;

    public ConsumptionListBean(Long recordId, UID consumptionUid, Double totalPrice, Double finalPrice, Long time, String shopUID, String shopName, Long accumulatePoints, UID customerUid, String customerName, String weChatId) {
        setRecordId(recordId);
        setConsumptionUid(consumptionUid);
        setTotalPrice(totalPrice);
        setFinalPrice(finalPrice);
        setTime(time);
        setShopUID(shopUID);
        setShopName(shopName);
        setAccumulatePoints(accumulatePoints);
        setCustomerUid(customerUid);
        setCustomerName(customerName);
        setWeChatId(weChatId);
    }

    public ConsumptionListBean() {
    }

    public ConsumptionListBean duplicate() {
        ConsumptionListBean result = new ConsumptionListBean();
        result.recordId = this.recordId;
        result.consumptionUid = this.consumptionUid;
        result.totalPrice = this.totalPrice;
        result.finalPrice = this.finalPrice;
        result.time = this.time;
        result.shopUID = this.shopUID;
        result.shopName = this.shopName;
        result.accumulatePoints = this.accumulatePoints;
        result.customerUid = this.customerUid;
        result.customerName = this.customerName;
        result.weChatId = this.weChatId;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public Long getRecordId() {
        return recordId;
    }

    public void  setRecordId(Long value) {
        this.recordId = value;
    }

    public ConsumptionListBean withRecordId(Long value) {
        setRecordId(value);
        return this;
    }

    public ConsumptionListBean withRecordId(Long value, Long defaultValue) {
        setRecordId(value == null ? defaultValue : value);
        return this;
    }

    public UID getConsumptionUid() {
        return consumptionUid;
    }

    public void  setConsumptionUid(UID value) {
        this.consumptionUid = value;
    }

    public ConsumptionListBean withConsumptionUid(UID value) {
        setConsumptionUid(value);
        return this;
    }

    public ConsumptionListBean withConsumptionUid(UID value, UID defaultValue) {
        setConsumptionUid(value == null ? defaultValue : value);
        return this;
    }

    public Double getTotalPrice() {
        return totalPrice;
    }

    public void  setTotalPrice(Double value) {
        this.totalPrice = value;
    }

    public ConsumptionListBean withTotalPrice(Double value) {
        setTotalPrice(value);
        return this;
    }

    public ConsumptionListBean withTotalPrice(Double value, Double defaultValue) {
        setTotalPrice(value == null ? defaultValue : value);
        return this;
    }

    public Double getFinalPrice() {
        return finalPrice;
    }

    public void  setFinalPrice(Double value) {
        this.finalPrice = value;
    }

    public ConsumptionListBean withFinalPrice(Double value) {
        setFinalPrice(value);
        return this;
    }

    public ConsumptionListBean withFinalPrice(Double value, Double defaultValue) {
        setFinalPrice(value == null ? defaultValue : value);
        return this;
    }

    public Long getTime() {
        return time;
    }

    public void  setTime(Long value) {
        this.time = value;
    }

    public ConsumptionListBean withTime(Long value) {
        setTime(value);
        return this;
    }

    public ConsumptionListBean withTime(Long value, Long defaultValue) {
        setTime(value == null ? defaultValue : value);
        return this;
    }

    public String getShopUID() {
        return shopUID;
    }

    public void  setShopUID(String value) {
        this.shopUID = value;
    }

    public ConsumptionListBean withShopUID(String value) {
        setShopUID(value);
        return this;
    }

    public ConsumptionListBean withShopUID(String value, String defaultValue) {
        setShopUID(value == null ? defaultValue : value);
        return this;
    }

    public String getShopName() {
        return shopName;
    }

    public void  setShopName(String value) {
        this.shopName = value;
    }

    public ConsumptionListBean withShopName(String value) {
        setShopName(value);
        return this;
    }

    public ConsumptionListBean withShopName(String value, String defaultValue) {
        setShopName(value == null ? defaultValue : value);
        return this;
    }

    public Long getAccumulatePoints() {
        return accumulatePoints;
    }

    public void  setAccumulatePoints(Long value) {
        this.accumulatePoints = value;
    }

    public ConsumptionListBean withAccumulatePoints(Long value) {
        setAccumulatePoints(value);
        return this;
    }

    public ConsumptionListBean withAccumulatePoints(Long value, Long defaultValue) {
        setAccumulatePoints(value == null ? defaultValue : value);
        return this;
    }

    public UID getCustomerUid() {
        return customerUid;
    }

    public void  setCustomerUid(UID value) {
        this.customerUid = value;
    }

    public ConsumptionListBean withCustomerUid(UID value) {
        setCustomerUid(value);
        return this;
    }

    public ConsumptionListBean withCustomerUid(UID value, UID defaultValue) {
        setCustomerUid(value == null ? defaultValue : value);
        return this;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void  setCustomerName(String value) {
        this.customerName = value;
    }

    public ConsumptionListBean withCustomerName(String value) {
        setCustomerName(value);
        return this;
    }

    public ConsumptionListBean withCustomerName(String value, String defaultValue) {
        setCustomerName(value == null ? defaultValue : value);
        return this;
    }

    public String getWeChatId() {
        return weChatId;
    }

    public void  setWeChatId(String value) {
        this.weChatId = value;
    }

    public ConsumptionListBean withWeChatId(String value) {
        setWeChatId(value);
        return this;
    }

    public ConsumptionListBean withWeChatId(String value, String defaultValue) {
        setWeChatId(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch(name) {
        case "recordId": return getRecordId();
        case "consumptionUid": return getConsumptionUid();
        case "totalPrice": return getTotalPrice();
        case "finalPrice": return getFinalPrice();
        case "time": return getTime();
        case "shopUID": return getShopUID();
        case "shopName": return getShopName();
        case "accumulatePoints": return getAccumulatePoints();
        case "customerUid": return getCustomerUid();
        case "customerName": return getCustomerName();
        case "weChatId": return getWeChatId();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if(!(o instanceof ConsumptionListBean)) return false;
        return signature().equals(((ConsumptionListBean)o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean ConsumptionListBean has no signature defined, no hash code or equals possible.");
    }
}
